<template>
  <kaitouVue></kaitouVue>
  <!-- <nav>
    <router-link to="/">Home</router-link> |
    <router-link to="/about" target="_blank">About</router-link>
  </nav> -->
  <router-view />
</template>
<script lang="ts">
import { defineComponent } from "vue";
import kaitouVue from "./components/kaitou/kaitou.vue";
import { useRouter } from "vue-router";

export default defineComponent({
  name: "HomeView",
  components: {
    kaitouVue,
  },
  setup(props) {
    const router = useRouter();
    //禁止ctrl复制
    // window.addEventListener("keydown", (e: any) => {
    //   // document.onkeydown = function (ev) {
    //   let ev: Event = window.event || e;
    //   if (ev.ctrlKey && ev.keyCode == 67) {
    //     ev.returnValue = false;
    //     alert("Ctrl+C被禁止啦！");
    //   }
    //   // };
    // });

    //App.vue
    function _isMobile(): RegExpMatchArray {
      // navigator 	返回由客户机发送服务器的user-agent 头部的值 判断设备
      let flag: RegExpMatchArray = navigator.userAgent.match(
        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
      );
      return flag;
    }
    function isPCmobile(): void {
      // 判断设备是否为移动端
      if (_isMobile()) {
        console.log("移动端");
        router.push("/about");
      } else {
        console.log("pc端");
        router.push("/");
      }
    }
    isPCmobile();
    return {};
  },
});
</script>
<style lang="less">
@import url(./style/index.less);

</style>
